{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "iCopy.ipynb",
      "provenance": [],
      "collapsed_sections": [],
      "authorship_tag": "ABX9TyMIOr05NhpujkN2XObP9vC3",
      "include_colab_link": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "accelerator": "GPU"
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/Godcic/iCopy-Heroku/blob/master/iCopy.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "NZUNVC5FMrc1",
        "colab_type": "code",
        "cellView": "form",
        "colab": {}
      },
      "source": [
        "#@markdown <h3><b>←</b> Run this cell to install all required modules </h3>\n",
        "!sudo add-apt-repository ppa:deadsnakes/ppa -y\n",
        "!sudo apt update\n",
        "!sudo apt install unzip\n",
        "!sudo apt install python3.8\n",
        "!sudo apt-get install python3.8-venv\n",
        "!sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 3\n",
        "!curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py\n",
        "!python3 get-pip.py --force-reinstall\n",
        "!pip3 install -U pip\n",
        "!git clone https://github.com/Godcic/iCopy-Heroku.git\n",
        "%cd /content/iCopy-Heroku\n",
        "!pip3 install -r requirements.txt\n",
        "!bash <(wget -qO- https://git.io/JJYE0)\n",
        "from IPython.display import HTML, clear_output\n",
        "clear_output()\n",
        "print(\"Successfully Installed\")\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "QsbKzy_7my1L",
        "colab_type": "code",
        "cellView": "form",
        "colab": {}
      },
      "source": [
        "#@markdown <h3><b>←</b>Fill all the Vars and Run the cell</h3>\n",
        "BOT_TOKEN = \"\" #@param {type:\"string\"}\n",
        "USER_ID = \"\" #@param {type:\"string\"}\n",
        "DB_CONNECT_METHOD =\"mongodb+srv\"#@param {type:\"string\"}\n",
        "DB_ADDRESS = \"\"#@param {type:\"string\"}\n",
        "DB_PORT=\"27017\"#@param {type:\"string\"}\n",
        "DB_NAME=\"iCopy\"#@param {type:\"string\"}\n",
        "DB_USERNAME=\"\"#@param {type:\"string\"}\n",
        "DB_PASS=\"\"#@param {type:\"string\"}\n",
        "LANGUAGE=\"cn\"#@param {type:\"string\"}\n",
        "CLONER=\"fclone\"#@param {type:\"string\"}\n",
        "OPTION=\"copy\"#@param {type:\"string\"}\n",
        "RCLONE_RMT=\"iCopy\"#@param {type:\"string\"}\n",
        "PARALLEL_CHECKERS=\"2500\"#@param {type:\"string\"}\n",
        "PARALLEL_TRANSFERS=\"2500\"#@param {type:\"string\"}\n",
        "MIN_SLEEP=\"1ms\"#@param {type:\"string\"}\n",
        "SA_INIT_FILE=\"\"#@param {type:\"string\"}\n",
        "SA_ZIP_URL=\"\"#@param {type:\"string\"}\n",
        "RUN_ARGS=\"['--log-level=DEBUG', '--log-file=/content/icopy_cloner_debug.log']\"\n",
        "SA_PATH = \"/content/iCopy-Heroku/iCopy/accounts\"\n",
        "import os\n",
        "os.environ['RCLONE_CONFIG']=\"/content/iCopy-Heroku/iCopy/config/rclone.conf\"\n",
        "%cd /content/iCopy-Heroku/iCopy/config/\n",
        "!echo -e \"[tg]\\n\"token = \"\\\"$BOT_TOKEN\\\"\\n\"usr_id = \"\\\"$USER_ID\\\"\\n[database]\\n\"db_connect_method = \"\\\"$DB_CONNECT_METHOD\\\"\\n\"db_addr = \"\\\"$DB_ADDRESS\\\"\\n\"db_port = \"$DB_PORT\"\"\\n\"db_name = \"\\\"$DB_NAME\\\"\\n\"db_user = \"\\\"$DB_USERNAME\\\"\\n\"db_passwd = \"\\\"$DB_PASS\\\"\\n[general]\\n\"language = \"\\\"$LANGUAGE\\\" \\n\"cloner = \"\\\"$CLONER\\\"\\n\"option = \"\\\"$OPTION\\\" \\n\"remote = \"\\\"$RCLONE_RMT\\\"\\n\"parallel_c = \"\\\"$PARALLEL_CHECKERS\\\"\\n\"parallel_t = \"\\\"$PARALLEL_TRANSFERS\\\"\\n\"min_sleep = \"\\\"$MIN_SLEEP\\\"\\n\"sa_path = \"\\\"$SA_PATH\\\"\\nrun_args = $RUN_ARGS\\n[web]\\ndashboard = 0\\nport = 8000\" >> conf.toml\n",
        "!echo \"[$RCLONE_RMT]\\ntype = drive\\nscope = drive\\n\"service_account_file = /app/iCopy/accounts/$SA_INIT_FILE\"\\n\"service_account_file_path = $SA_PATH\"\" >> rclone.conf\n",
        "%cd ..\n",
        "!wget --no-check-certificate -q $SA_ZIP_URL -O accounts.zip\n",
        "!unzip -qq accounts.zip -d /content/iCopy-Heroku/iCopy/"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "tJvoyAzBguoO",
        "colab_type": "code",
        "cellView": "form",
        "colab": {}
      },
      "source": [
        "#@markdown <h3><b>←</b>Run this cell to start the Bot</h3>\n",
        "%cd /content/iCopy-Heroku/iCopy/\n",
        "!chmod 777 iCopy.py\n",
        "!python3 iCopy.py"
      ],
      "execution_count": null,
      "outputs": []
    }
  ]
}